home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 139
/
(Vol 139) Sep 24 2011.iso
/
Games
/
sheep_are_save.swf
/
scripts
/
frame_1
/
DoAction.as
< prev
Wrap
Text File
|
2011-09-24
|
15KB
|
765 lines
function min(a, b)
{
if(a < b)
{
return a;
}
return b;
}
function playSnd(lib_snd)
{
s = new Sound(this);
s.attachSound(lib_snd);
s.start();
}
function stopMySound()
{
stopSoundFlag = true;
mc_sloop.gotoAndStop(3);
}
function startMySound()
{
stopSoundFlag = false;
if(!pauseFlag)
{
mc_sloop.gotoAndStop(2);
}
}
function startGame()
{
level = 0;
nextLevel();
set("/gametablo:scores",0);
setProperty("/gametablo", _visible, true);
}
function gameOver()
{
this.gotoAndPlay("lamo");
mc_sloop.gotoAndStop(3);
}
function gameWin()
{
set("/gametablo:scores",Number(eval("/gametablo:scores")) + scrLevel);
this.gotoAndStop("rul");
mc_sloop.gotoAndStop(3);
}
function nextLevel()
{
this.gotoAndStop("startgame");
if(!stopSoundFlag)
{
mc_sloop.gotoAndStop(2);
}
}
function newGame()
{
setProperty("/Game", _visible, 0);
this.Stop();
setProperty("/Rating", _visible, 1);
tellTarget("/Rating")
{
gotoAndStop("Save");
}
stop();
}
function startPause()
{
pauseFlag = true;
mc_sloop.gotoAndStop(3);
m1.pG.stop();
i = 1;
while(wfC >= i)
{
wfA[i].pGo.stop();
wfA[i].pGl.stop();
i++;
}
}
function stopPause()
{
pauseFlag = false;
if(!stopSoundFlag)
{
mc_sloop.gotoAndStop(2);
}
m1.pG.play();
i = 1;
while(wfC >= i)
{
wfA[i].pGo.play();
wfA[i].pGl.play();
i++;
}
}
stopSoundFlag = false;
mP = 57.29577951308232;
mPo = 0.017453292519943295;
h2 = 16;
h22 = 24;
Sheep = function(parent, num, minSpeed, maxSpeed, rotateSpeed, wayLong, rotateLong, runInCenter)
{
this.p = parent;
this.numL = num;
this.minS = minSpeed;
this.maxS = maxSpeed;
this.riS = runInCenter;
this.cS = 0;
this.rtS = rotateSpeed;
this.rtD = 1;
this.wL = wayLong;
this.wC = 0;
this.rtL = rotateLong;
this.vx = 0;
this.vy = 0;
this.fx = this.p._x;
this.fy = this.p._y;
this.st = 0;
this.tdT = 3;
};
Sheep.prototype.sGo = function()
{
saC++;
if(random(3) == 0)
{
this.st = 2;
if(random(2) == 0)
{
this.rtD = 1;
}
else
{
this.rtD = -1;
}
}
else
{
this.st = 1;
this.cS = random(this.maxS - this.minS) + this.minS;
this.vx = Math.sin(this.p._rotation * mPo);
this.vy = - Math.cos(this.p._rotation * mPo);
}
this.wC = 0;
};
Sheep.prototype.calcXY = function()
{
if(this.st == 1)
{
this.fx = this.p._x + this.vx * this.cS;
this.fy = this.p._y + this.vy * this.cS;
}
};
Sheep.prototype.goto = function()
{
this.wC = this.wC + 1;
if(this.st == 1)
{
this.p._x = this.fx;
this.p._y = this.fy;
with(this)
{
if(p._x < 0 || 520 < p._x || p._y < 0 || 390 < p._y)
{
die();
}
}
if(this.wL < this.wC)
{
this.st = 0;
saC--;
}
}
else if(this.st == 2)
{
this.p._rotation += this.rtD * this.rtS;
if(this.rtL < this.wC)
{
this.st = 0;
saC--;
}
}
if(this.st == 3)
{
if(this.wC >= this.tdT)
{
this.die();
}
}
};
Sheep.prototype.r90 = function()
{
if(random(2) == 0)
{
k = 1;
}
else
{
k = -1;
}
this.vx = (- this.vy) * k;
this.vy = this.vx * k;
this.p._rotation = Math.atan2(this.vx,- this.vy) * mP;
};
Sheep.prototype.hT = function(obj)
{
if(Math.abs(this.fx - obj._x) < h2 && Math.abs(this.fy - obj._y) < h2)
{
return true;
}
return false;
};
Sheep.prototype.boom = function()
{
if(this.st == 1 || this.st == 2)
{
saC--;
}
this.st = 3;
this.wC = 0;
nn.mc_boom.duplicateMovieClip("pBoom",1000 + this.numL);
with(nn.pBoom)
{
_visible = true;
_x = this.p._x;
_y = this.p._y;
}
};
Sheep.prototype.die = function()
{
if(this.st == 1 || this.st == 2)
{
saC--;
}
with(this)
{
st = 4;
p._visible = false;
p._x = p._y = -1000;
}
saD++;
};
Sheep.prototype.run = function()
{
if(this.st == 0)
{
saC++;
}
with(this)
{
wC = 0;
st = 1;
cS = riS;
}
with(this)
{
tmpI = Math.atan2(p._x - 260,p._y - 195) * mP;
p._rotation = - tmpI;
vx = Math.sin(p._rotation * mPo);
vy = - Math.cos(p._rotation * mPo);
}
playSnd("lib_sheep");
};
Wolf = function(baseLevel, pNum, minSpeed, maxSpeed, pauseTime, goTime, dieTime, glukTime, glukAmount)
{
this.name = "w" add pNum;
nn.attachMovie("lib_wolf",this.name,baseLevel + pNum * 3 + 1);
nn.attachMovie("lib_wolf_Go",this.name + "g",baseLevel + pNum * 3);
nn.attachMovie("lib_wolf_gluk",this.name + "gl",baseLevel + pNum * 3 + 2);
tellTarget("nn." + this.name)
{
_X = _Y = -2000;
c1._visible = c2._visible = _visible = false;
}
tellTarget("nn." + this.name + "g")
{
_X = _Y = 0;
c1._visible = c2._visible = _visible = false;
}
tellTarget("nn." + this.name + "gl")
{
_X = _Y = 0;
c1._visible = c2._visible = _visible = false;
}
this.p = eval("nn." + this.name);
this.pGo = eval("nn." + this.name + "g");
this.pGl = eval("nn." + this.name + "gl");
this.vx = 0;
this.vy = 0;
this.minS = minSpeed;
this.maxS = maxSpeed;
this.cS = 0;
this.st = 0;
this.pT = pauseTime;
this.gT = goTime;
this.pC = 0;
this.sF = true;
this.dT = dieTime;
this.glT = glukTime;
this.glA = glukAmount;
this.glC = 0;
};
Wolf.prototype.rem = function()
{
removeMovieClip("nn." + this.name);
};
Wolf.prototype.sGo = function()
{
with(this)
{
cS = random(maxS - minS) + minS;
}
tmpI = random(360);
this.vx = Math.sin(tmpI * mPo);
this.vy = Math.cos(tmpI * mPo);
a = 60;
k = Math.abs(this.vy / this.vx);
x = 260 + a;
y = k * x;
y0 = 195 + a;
if(y0 < y)
{
y = y0;
x = y / k;
}
if(this.vx < 0)
{
x = - x;
}
if(this.vy < 0)
{
y = - y;
}
this.pGo._x = 260 + x;
this.pGo._y = 195 + y;
with(this)
{
pGo._visible = true;
vx = - vx;
vy = - vy;
tmpI = Math.atan2(vx,vy) * mP;
pGo._rotation = - tmpI + 90;
st = 1;
pC = 0;
}
};
Wolf.prototype.goto = function()
{
with(this)
{
if(sF)
{
return undefined;
}
if(st == 0)
{
if(dT < pC)
{
sGo();
}
}
else if(st == 1)
{
pGo._x += vx * cS;
pGo._y += vy * cS;
if(pT < pC)
{
pC = 0;
st = 2;
sF = true;
pGo._visible = false;
p._x = pGo._x;
p._y = pGo._y;
p._rotation = pGo._rotation;
p._visible = true;
}
}
else if(st == 2)
{
if(pT < pC)
{
pC = 0;
st = 1;
p._visible = false;
pGo._visible = true;
}
}
}
};
Wolf.prototype.sheepAm = function()
{
with(this)
{
st = 3;
sF = true;
pC = 0;
p._visible = false;
pGo._visible = false;
p._x = pGo._x;
p._y = pGo._y;
}
nn.mc_topt1.duplicateMovieClip("pTpt1",2000 + this.pNum);
nn.pTpt1._x = this.p._x;
nn.pTpt1._y = this.p._y;
nn.pTpt1._rotation = this.p._rotation;
nn.pTpt1._visible = true;
nn.pTpt1.sender = this;
};
Wolf.prototype.pasAm = function()
{
with(this)
{
st = 4;
sF = true;
pC = 0;
p._visible = false;
pGo._visible = false;
p._x = pGo._x;
p._y = pGo._y;
}
nn.mc_topt2.duplicateMovieClip("pTpt2",2500 + this.pNum);
nn.pTpt2._x = this.p._x;
nn.pTpt2._y = this.p._y;
nn.pTpt2._rotation = this.p._rotation;
nn.pTpt2._visible = true;
nn.pTpt2.sender = this;
nn._parent.eFlag = true;
};
Wolf.prototype.goToDie = function()
{
with(this)
{
sF = true;
st = 0;
pC = 0;
pGo._x = pGo._y = p._x = p._y = -2000;
pGo._visible = p._visible = false;
glC = 0;
}
};
Wolf.prototype.next = function()
{
with(this)
{
if(st == 3)
{
sF = true;
pC = 0;
st = 2;
p._visible = true;
pGo._visible = false;
}
else if(st == 4)
{
p._parent._parent.gameOver();
}
}
};
Wolf.prototype.hT = function(obj)
{
if(this.st == 2)
{
if(this.p.c1.hitTest(obj))
{
return true;
}
if(this.p.c2.hitTest(obj))
{
return true;
}
}
else if(this.st == 1)
{
if(this.pGo.c1.hitTest(obj))
{
return true;
}
if(this.pGo.c2.hitTest(obj))
{
return true;
}
}
return false;
};
Wolf.prototype.hTo = function(obj)
{
if(this.st == 2)
{
if(this.p.c1.hitTest(obj.pU.c))
{
return true;
}
if(this.p.c2.hitTest(obj.pU.c))
{
return true;
}
}
else if(this.st == 1)
{
if(this.pGo.c1.hitTest(obj.pU.c))
{
return true;
}
if(this.pGo.c2.hitTest(obj.pU.c))
{
return true;
}
}
return false;
};
Wolf.prototype.gluk = function()
{
with(this)
{
st = 5;
sF = true;
pC = 0;
pGo._visible = p._visible = false;
p._x = pGl._x = pGo._x;
p._y = pGl._y = pGo._y;
pGl._visible = true;
pGl._rotation = pGo._rotation;
}
playSnd("lib_wattack");
};
Wolf.prototype.gluCheck = function()
{
with(this)
{
if(st == 5)
{
if(glT < pC)
{
pC = 0;
st = 2;
p._visible = true;
pGo._visible = false;
pGl._visible = false;
pGl._x = pGl._y = -5000;
glC++;
if(glC == glA)
{
die();
}
return undefined;
}
}
else if(st == 6)
{
if(pC >= 3)
{
goToDie();
}
}
}
};
Wolf.prototype.die = function()
{
with(this)
{
st = 6;
pC = 0;
sF = true;
p._visible = true;
pGo._visible = false;
}
nn.mc_boom.duplicateMovieClip("pBoom",6000 + this.numL);
with(nn.pBoom)
{
_visible = true;
_x = this.pGo._x;
_y = this.pGo._y;
_xscale = _yscale = 150;
}
set("/gametablo:scores",Number(eval("/gametablo:scores")) + scrWolf);
};
Man = function(parent, parentGo, parentShoot, parentFire)
{
this.p = parent;
this.pG = parentGo;
this.pS = parentShoot;
this.pF = parentFire;
this.pU = this.p;
with(this)
{
pF._x = pF._y = pS._x = pS._y = -3000;
pF._visible = pG._visible = pS._visible = false;
pG._x = p._x;
pG._y = p._y;
}
pS.stop();
this.st = 0;
this.shA = false;
this.sh = false;
this.shF = false;
this.fr = false;
this.fx = this.p._x;
this.fy = this.p._y;
};
Man.prototype.goto = function(hit)
{
with(this)
{
if(!hit)
{
pG._x = p._x = fx;
pG._y = p._y = fy;
}
}
};
Man.prototype.calcXY = function()
{
with(this)
{
txa = Math.abs(tx = _xmouse - fx);
tya = Math.abs(ty = _ymouse - fy);
tr = txa + tya;
pG._rotation = p._rotation = (u = Math.atan2(tx,- ty)) * mP;
if(tr < 8)
{
if(st == 1)
{
st = 0;
pG._visible = false;
p._visible = true;
pU = p;
}
return undefined;
}
if(st == 0)
{
st = 1;
p._visible = false;
pG._visible = true;
pU = pG;
}
dY = min(int(tr - 8),10);
if(dY < 0.0001)
{
if(st == 1)
{
st = 0;
pG._visible = false;
p._visible = true;
pU = p;
}
}
fx = p._x + dY * Math.sin(u);
fy = p._y - dY * Math.cos(u);
if(0 >= fx)
{
fx = 0;
}
if(520 < fx)
{
fx = 520;
}
if(0 >= fy)
{
fy = 0;
}
if(390 < fy)
{
fy = 390;
}
}
};
Man.prototype.shoot = function()
{
with(this)
{
pG._visible = p._visible = false;
pS.duplicateMovieClip("pShoot",3000);
nn.pShoot._visible = true;
nn.pShoot._x = p._x;
nn.pShoot._y = p._y;
nn.pShoot._rotation = p._rotation;
nn.pShoot.sender = this;
pU = nn.pShoot;
shA = true;
}
playSnd("lib_knut");
};
Man.prototype.endSh = function()
{
if(st == 2)
{
return undefined;
}
with(this)
{
shA = false;
if(st == 0)
{
p._visible = true;
pU = p;
}
else
{
pG._visible = true;
pU = pG;
}
}
};
Man.prototype.fire = function()
{
with(this)
{
pG._visible = p._visible = false;
pF.duplicateMovieClip("pFire",3000);
nn.pFire._visible = true;
nn.pFire._x = p._x;
nn.pFire._y = p._y;
nn.pFire._rotation = p._rotation;
nn.pFire.sender = this;
pU = nn.pFire;
shF = true;
}
playSnd("lib_shoot");
};
Man.prototype.endF = function()
{
if(st == 2)
{
return undefined;
}
with(this)
{
shF = false;
if(st == 0)
{
p._visible = true;
pU = p;
}
else
{
pG._visible = true;
pU = pG;
}
}
};
Man.prototype.hTf = function(obj)
{
if(Math.abs(this.fx - obj.fx) < h2 + 14 && Math.abs(this.fy - obj.fy) < h2 + 14)
{
return true;
}
return false;
};
Man.prototype.hT = function(obj)
{
if(Math.abs(this.fx - obj._x) < h2 + 14 && Math.abs(this.fy - obj._y) < h2 + 14)
{
return true;
}
return false;
};
Man.prototype.die = function()
{
with(this)
{
p._x = p._y = pG._x = pG._y = -3000;
p._visible = pG._visible = false;
st = 2;
}
nn.pFire._visible = nn.pShoot._visible = false;
};